import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

import GO from '@/views/limit/go.vue'
import User from '@/views/limit/user.vue'
import Menu from '@/views/limit/menu.vue'
import Role from '@/views/limit/role.vue'
import Organization from '@/views/organization/organization'
import Service from '@/views/service/service'
import Team from '@/views/team/team'
import FollowForms from '@/views/followForms/followForms'
import ResidentHealth from '@/views/followForms/components/resident-health'
import FirstInspect from '@/views/followForms/components/firstInspect'
import SecondInspect from '@/views/followForms/components/secondInspect'
import FormsQuery from '@/views/followForms/components/formsQuery'
import HigHpressure from '@/views/followForms/components/higHpressure'
import Stroke from '@/views/followForms/components/stroke'
import SevereMental from '@/views/followForms/components/severeMental'


import Coronary from '@/views/followForms/components/coronary'

import Diabetes from '@/views/followForms/components/diabetes'

import SignContract from '@/views/serviceAdmin/signContract'
import Performance from '@/views/Performance/Performance'
import PostpartumVisit from '@/views/followForms/components/postpartumVisit'
import PostpartumVisit42 from '@/views/followForms/components/postpartumVisit42'
import Newborn from '@/views/followForms/components/newborn'
import TwelveToEight from '@/views/followForms/components/twelveToEight'
import ThreeYearsEight from '@/views/followForms/components/threeYearsEight'
import Psychogeny from '@/views/followForms/components/psychogeny'
import TuberculosisFirst from '@/views/followForms/components/tuberculosisFirst'
import TuberculosisFollow from '@/views/followForms/components/tuberculosisFollow'
import AgedHealth from '@/views/followForms/components/agedHealth'


import OneToEight from '@/views/followForms/components/oneToEight'
import rescindContract from '@/views/rescindContract/rescindContract'
import dashboardAdmin from '@/views/dashboard/admin/index'
import dashboardHospital from '@/views/dashboard/hospatil/index'

/* Router Modules */
// import componentsRouter from './modules/components'
// import chartsRouter from './modules/charts'
// import tableRouter from './modules/table'
// import nestedRouter from './modules/nested'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar
    noCache: true                if set true, the page will no be cached(default is false)
    affix: true                  if set true, the tag will affix in the tags-view
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [{
        path: '/redirect',
        name: 'redirect',
        component: Layout,
        hidden: true,
        children: [{
            path: '/redirect/:path(.*)',
            component: () =>
                import ('@/views/redirect/index')
        }]
    },
    {
        path: '/login',
        component: () =>
            import ('@/views/login/index'),
        hidden: true
    },
    {
        path: '/auth-redirect',
        component: () =>
            import ('@/views/login/auth-redirect'),
        hidden: true
    },
    {
        path: '/404',
        component: () =>
            import ('@/views/error-page/404'),
        hidden: true
    },
    {
        path: '/401',
        component: () =>
            import ('@/views/error-page/401'),
        hidden: true
    },
    {
        path: '/go',
        component: GO,
        hidden: true,
        children: [{
                path: '/user',
                component: User,
            },
            {
                path: '/menu',
                component: Menu,
            },
            {
                path: '/role',
                component: Role,
            },
            {
                path: '/organization',
                component: Organization,
            },
            {
                path: '/service',
                component: Service,
            },
            {
                path: '/team',
                component: Team,
            },
            {
                path: '/followForms',
                component: FollowForms,
            },
            {
                path: '/psychogeny',
                component: Psychogeny,
            },
            {
                path: '/tuberculosisFirst',
                component: TuberculosisFirst,
            },
            {
                path: '/tuberculosisFollow',
                component: TuberculosisFollow,
            },
            {
                path: '/agedHealth',
                component: AgedHealth,
            },
            {
                path: '/severeMental',
                component: SevereMental,
            },
            {
                path: '/residentHealth',
                component: ResidentHealth,
            },
            {
                path: '/firstInspect',
                component: FirstInspect,
            },
            {
                path: '/diabetes',
                component: Diabetes,
            },

            {
                path: '/secondInspect',
                component: SecondInspect,
            },
            {
                path: '/higHpressure',
                component: HigHpressure,
            },
            {
                path: '/coronary',
                component: Coronary,
            },
            {
                path: '/stroke',
                component: Stroke,
            },


            {
                path: '/twelveToEight',
                component: TwelveToEight,
            },
            {
                path: '/threeYearsEight',
                component: ThreeYearsEight,
            },



            {
                path: '/formsQuery',
                component: FormsQuery,
            },
            {
                path: '/signContract',
                component: SignContract,
            },
            {
                path: '/performance',
                component: Performance,
            },
			{
				path: '/rescindContract',
				component: rescindContract,
			},
            {
                path: '/postpartumVisit',
                component: PostpartumVisit,
            },
            {
                path: '/postpartumVisit42',
                component: PostpartumVisit42,
            },
            {
                path: '/newborn',
                component: Newborn,
            },
            {
                path: '/oneToEight',
                component: OneToEight,
            },
			{
			    path: '/dashboard/admin/index',
			    component: dashboardAdmin,
			},
			{
			    path: '/dashboard/hospital/index',
			    component: dashboardHospital,
			},




        ]
    },
]

/**
 * asyncRoutes
 * the routes that need to be dynamically loaded based on user roles
 */
export const asyncRoutes = []

const createRouter = () => new Router({
    scrollBehavior: () => ({
        y: 0
    }),
    routes: constantRoutes
})

const router = createRouter()


export function resetRouter() {
    const newRouter = createRouter()
    router.matcher = newRouter.matcher // reset router
}

export default router
